package com.kla.power.mapper;

import com.kla.power.entity.MenuEntity;
import com.kla.power.entity.RoleMenuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 角色权限表 Mapper 接口
 * </p>
 *
 * @author WuZH
 * @since 2024-06-02
 */
@Mapper
public interface RoleMenuMapper extends BaseMapper<RoleMenuEntity> {


    @Insert (value = "INSERT INTO role_menu_info(id,roleId,menuId,createTime) value(#{roleMenuEntity.id},#{roleMenuEntity.roleId},#{roleMenuEntity.menuId},#{roleMenuEntity.createTime})")
    Integer saveSingle (@Param ("roleMenuEntity") RoleMenuEntity roleMenuEntity);

    @Delete (value = "DELETE FROM role_menu_info WHERE roleId=#{roleMenuEntity.roleId}")
    Integer deleteBatch (@Param ("roleMenuEntity") RoleMenuEntity roleMenuEntity);

    @Select ( value = "select mi.id,mi.menuName,mi.url,mi.note,mi.type,mi.sort,mi.parentId from role_menu_info rmi left join menu_info mi on rmi.menuId=mi.id where rmi.roleId=#{roleMenuEntity.roleId}")
    List<MenuEntity> queryList(@Param ("roleMenuEntity") RoleMenuEntity roleMenuEntity);

}
